﻿using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using QuickPrompt.DomainModel;
using RedandBlue.RepositoryPattern.EF6;

namespace QuickPrompt.Test.UnitTests.Fake
{
    //public class UserDbSet : FakeDbSet<User>
    //{
    //    public override User Find(params object[] keyValues)
    //    {
    //        return this.SingleOrDefault(t => t.UserId == (int)keyValues.FirstOrDefault());
    //    }

    //    public override Task<User> FindAsync(CancellationToken cancellationToken, params object[] keyValues)
    //    {
    //        return new Task<User>(() => Find(keyValues));
    //    }
    //}

    public class QuickNoteDbSet : FakeDbSet<QuickNote>
    {
        public override QuickNote Find(params object[] keyValues)
        {
            return this.SingleOrDefault(t => t.UserGuid == (string)keyValues.FirstOrDefault());
        }

        public override Task<QuickNote> FindAsync(CancellationToken cancellationToken, params object[] keyValues)
        {
            return new Task<QuickNote>(() => Find(keyValues));
        }
    }

    public class PromptDbSet : FakeDbSet<Prompt>
    {
        public override Prompt Find(params object[] keyValues)
        {
            return this.SingleOrDefault(t => t.Id == (int)keyValues.FirstOrDefault());
        }

        public override Task<Prompt> FindAsync(CancellationToken cancellationToken, params object[] keyValues)
        {
            return new Task<Prompt>(() => Find(keyValues));
        }
    }
}
